package com.wzdigit.wms.ws.config.ws;
/*
 * @Author:yangwenbiao
 * @Date 2021/5/15 1:12 PM
 * @version 1.0
 */

import com.wzdigit.wms.ws.service.gdn.GdnService;
import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.xml.ws.Endpoint;

@Configuration
public class WebServiceConfig {

    @Autowired
    GdnService gdnService;

//    @Autowired
//    AsnService asnService;

    @Bean(name = Bus.DEFAULT_BUS_ID)
    public SpringBus springBus() {
        return new SpringBus();
    }

    @Bean
    public ServletRegistrationBean cxfServlet() {
        return new ServletRegistrationBean(new CXFServlet(),"/webservice/*");
    }

    @Bean
    public Endpoint endpoint() {

        EndpointImpl endpoint = new EndpointImpl(springBus(), gdnService);
        endpoint.publish("/gdnService/api");

//        EndpointImpl endpoint1 = new EndpointImpl(springBus(), asnService);
//        endpoint.publish("/asnService/api");

        return endpoint;
    }

//    @Bean
//    public Endpoint endpoint1() {
//        EndpointImpl endpoint1 = new EndpointImpl(springBus(), asnService);
//        endpoint1.publish("/asnService/api");
//        return endpoint1;
//    }
}
